const path = require("path");
function resolve(dir) {
    return path.join(__dirname, dir);
}
module.exports = {
    // 基本路径
    // baseUrl: '/dist',//与网址输出的地址一致
    // baseUrl:"/",
    // 输出文件目录
    outputDir: "dist",
    // eslint-loader 是否在保存的时候检查
    lintOnSave: true,
    // use the full build with in-browser compiler?
    // https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only
    // compiler: false,
    // webpack配置
    // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
    chainWebpack: config => {
        //设置别名
        config.resolve.alias
            .set("@$", resolve("src"))
            .set("store", resolve("src/store"))
            .set("assets", resolve("src/assets"))
            .set("components", resolve("src/components"))
            .set("layout", resolve("src/layout"))
            .set("base", resolve("src/base"))
            .set("@css", resolve("src/assets/css"))
            .set("@utils", resolve("src/assets/utils"))
            .set("@api", resolve("src/assets/api"))
            .set("@images", resolve("src/assets/images"))
            .set("static", resolve("src/static"));
        // config.module
        //     .rule('sass')
        //     .use('sass-loader')
        //     .tap(options=>{
        //         merge(options, {
        //             includePaths: [path.resolve(__dirname, 'node_modules')],
        //         })
        //     })
    },
    configureWebpack: () => {},
    // vue-loader 配置项
    // https://vue-loader.vuejs.org/en/options.html
    // vueLoader: {},
    // 生产环境是否生成 sourceMap 文件
    productionSourceMap: true,
    // css相关配置
    css: {
        // 是否使用css分离插件 ExtractTextPlugin
        extract: true,
        // 开启 CSS source maps?
        sourceMap: false,
        // css预设器配置项
        loaderOptions: {},
        // 启用 CSS modules for all css / pre-processor files.
        modules: false
    },
    // use thread-loader for babel & TS in production build
    // enabled by default if the machine has more than 1 cores
    parallel: require("os").cpus().length > 1,
    // 是否启用dll
    // See https://github.com/vuejs/vue-cli/blob/dev/docs/cli-service.md#dll-mode
    // dll: false,
    // PWA 插件相关配置
    // see https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
    pwa: {},
    // webpack-dev-server 相关配置
    devServer: {
        open: "Google chrome",
        host: "0.0.0.0",
        port: 8081,
        https: false,
        hotOnly: false,
        //设置代理：前端跨域请求(代理如果有多条默认第一条)
        proxy: {
            "/api": {
                //这个是http://127.0.0.1/api/user/name中紧挨在域名后面的那个参数
                target: "http://127.0.0.1"
                // ws: true,//是否启用websocket
                // changeOrigin: true //跨域时需要开启
                //pathRewrite: {"^/api" : ""},//此时路径可以是：http://localhost:3000/users,当api:api时，才是http://localhost:3000/api/users
                //secure: false//https是必须为true
            }
        },
        // 模拟数据（json数据模拟）
        before: app => {
            app.get("/api/seller", (req, res) => {
                res.json({
                    errno: 0,
                    message: "注册成功"
                });
            });
            app.get("/api/tableDatas", (req, res) => {
                res.json([
                    {
                        date: "2016-05-02",
                        name: "王小虎",
                        address: "上海市普陀区金沙江路 1518 弄"
                    },
                    {
                        date: "2016-05-04",
                        name: "王小虎",
                        address: "上海市普陀区金沙江路 1518 弄"
                    },
                    {
                        date: "2016-05-01",
                        name: "王小虎",
                        address: "上海市普陀区金沙江路 1518 弄"
                    },
                    {
                        date: "2016-05-03",
                        name: "王小虎",
                        address: "上海市普陀区金沙江路 1518 弄"
                    }
                ]);
            });
        }
    },
    // 第三方插件配置
    pluginOptions: {}
};
